// Translate.cpp: implementation of the Translate class.
//
//////////////////////////////////////////////////////////////////////

#include <cstdlib>
#include "Translate.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

void Translate::Initialise(Position &I0, Position &I1, Position &I2,
					 Position *P0, Position *P1, Position *P2,
					 double   *VX, double *VY,   double *VZ,
					 Pack	  *DX, Pack   *DY,   Pack   *DZ)
{
Initial[0]		= I0;
Initial[1]		= I1;
Initial[2]		= I2;

AtomPosition[0]	= P0;
AtomPosition[1]	= P1;
AtomPosition[2]	= P2;

Input[0]		= VX;
Input[1]		= VY;
Input[2]		= VZ;

Derivative[0]	= DX;
Derivative[1]	= DY;
Derivative[2]	= DZ;

Basis[0]		= Position(1.0, 0.0, 0.0);
Basis[1]		= Position(0.0, 1.0, 0.0);
Basis[2]		= Position(0.0, 0.0, 1.0);


for(int i=0;i<3;i++)
	{
	*(AtomPosition[i]) = Initial[i];

	if(Derivative[i] != NULL)
		{
		Derivative[i]->Vector1.Zero();
		Derivative[i]->Vector2 = Basis[i];
		}
	}
}

Translate::~Translate()
{

}

void Translate::Build()
{
Translation.Zero();

int i;

for(i=0;i<3;i++)
	Translation += *(Input[i]) * Basis[i];

for(i=0;i<3;i++)
	*(AtomPosition[i]) = Initial[i] + Translation;
}